/*
	@file Version: 0.1
	@file Name: statusBar.sqf
	@file  EpochMod StatusBar Port for Wasteland / EXILE by CRE4MPIE
	@file Created: 21/4/2015
	@notes: Added custom Icons and ported Wasteland info. Still 
			needs to be cleaned up a bit.
	=========================================================================
	Nov 09, 2016 - Modified to work with Escape by Omen from ZeroSurvival.com
	=========================================================================
*/

waitUntil {!(isNull (findDisplay 46))};
disableSerialization;

	_rscLayer = "osefStatusBarAdmin" call BIS_fnc_rscLayer;
	_rscLayer cutRsc["osefStatusBarAdmin","PLAIN"];
//	systemChat format["StatusBar Initialized", _rscLayer];
	[] spawn 
	{

		uiSleep 5;
		//set the color values.
		//Additional color codes can be found here:  http://html-color-codes.com/
		_colourDefault 	= parseText "#adadad"; //set your default colour here

		_uid = getPlayerUID player;	
	
		
	while {true} do 
	{
	
		uiSleep 1;
				
		//moved the creation of the status bar inside the loop and create it if it is null,
		//this is to handle instance where the status bar is disappearing 
		if(isNull ((uiNamespace getVariable "osefStatusBarAdmin")displayCtrl 55554)) then
		{
			diag_log "statusbar is null create";
			disableSerialization;
			_rscLayer = "osefStatusBarAdmin" call BIS_fnc_rscLayer;
			_rscLayer cutRsc["osefStatusBarAdmin","PLAIN"];
		};		
		
		//initialize variables and set values
		_unit = _this select 0;
		_damage = round ((1 - (damage player)) * 100);
		_serverFPS = round diag_fps;
		_money = player getVariable ["as_money", 0];
		
		//display the information 
		((uiNamespace getVariable "osefStatusBarAdmin")displayCtrl 55554)ctrlSetStructuredText parseText 
			format["
			<t shadow='1' shadowColor='#000000' color='%5'><img size='1.3'  shadowColor='#000000' image='addons\statusbar\icons\players.paa' color='%5'/> %2</t>
			<t shadow='1' shadowColor='#000000' color='%5'><img size='1.0'  shadowColor='#000000' image='addons\statusbar\icons\health.paa' color='%5'/> %3%1</t> 
			<t shadow='1' shadowColor='#000000' color='%5'><img size='1.0'  shadowColor='#000000' image='addons\statusbar\icons\fps.paa' color='%5'/> %4</t>
			<t shadow='1' shadowColor='#000000' color='%5'><img size='1.0'  shadowColor='#000000' image='addons\statusbar\icons\poptab_ca.paa' color='%5'/> %6</t>",		
					"%", 
					count allPlayers,
					_damage,
					_serverFPS,
					_colourDefault,
					_money
				];
		
		}; 
};
